inherited sprOtherDogovors: TsprOtherDogovors
  Left = 368
  Top = 221
  Caption = #1057#1087#1088#1072#1074#1086#1095#1085#1080#1082' '#1076#1086#1075#1086#1074#1086#1088#1086#1074' '#1085#1072' '#1087#1088#1086#1095#1080#1077' '#1087#1083#1072#1090#1077#1078#1080
  PixelsPerInch = 96
  TextHeight = 13
  inherited Panel2: TPanel
    Top = 25
    Height = 529
    inherited PageControl1: TPageControl
      Height = 529
      inherited tsTab: TTabSheet
        inherited GroupBox3: TGroupBox
          Height = 501
          inherited dbgRefer: TDBGridEh
            Height = 484
            Columns = <
              item
                EditButtons = <>
                FieldName = 'ID'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'GROUP_NAME'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'ORG_NAME'
                Footers = <>
              end
              item
                EditButtons = <>
                FieldName = 'DOGHEADER'
                Footers = <>
                Width = 174
              end
              item
                EditButtons = <>
                FieldName = 'USERORG_ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'RPT_GROUP_ID'
                Footers = <>
                Visible = False
              end
              item
                EditButtons = <>
                FieldName = 'PAY_RATE'
                Footers = <>
                Width = 97
              end
              item
                EditButtons = <>
                FieldName = 'IS_ACTIVE'
                Footers = <>
                Width = 95
              end>
          end
        end
      end
      inherited tsForm: TTabSheet
        inherited GroupBox2: TGroupBox
          Top = 0
          Width = 784
          Height = 415
          Align = alClient
          inherited pnlButtons: TPanel
            Top = 382
            Width = 780
            inherited SpeedButton1: TSpeedButton
              Left = 581
            end
            inherited SpeedButton2: TSpeedButton
              Left = 683
            end
          end
          object Panel1: TPanel
            Left = 2
            Top = 15
            Width = 454
            Height = 367
            Align = alLeft
            BevelOuter = bvNone
            TabOrder = 1
            object Label1: TLabel
              Left = 5
              Top = 27
              Width = 120
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1059#1089#1083#1091#1075#1072
            end
            object Label2: TLabel
              Left = 5
              Top = 51
              Width = 120
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1053#1072#1079#1085#1072#1095#1077#1085#1080#1077
            end
            object Label3: TLabel
              Left = 5
              Top = 75
              Width = 120
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1054#1088#1075'-'#1094#1080#1103' '#1087#1086#1083#1091#1095#1072#1090#1077#1083#1100
            end
            object Label4: TLabel
              Left = 5
              Top = 99
              Width = 120
              Height = 13
              Alignment = taRightJustify
              AutoSize = False
              Caption = #1057#1090#1072#1074#1082#1080' '#1082#1086#1084#1080#1089#1089#1080#1080
            end
            object lcbGroupName: TDBLookupComboboxEh
              Left = 132
              Top = 24
              Width = 313
              Height = 19
              AlwaysShowBorder = True
              DataField = 'RPT_GROUP_ID'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              KeyField = 'ID'
              ListField = 'NAME'
              ListSource = dsc_Groups
              TabOrder = 0
              Visible = True
            end
            object lcbOrgName: TDBLookupComboboxEh
              Left = 132
              Top = 48
              Width = 313
              Height = 19
              AlwaysShowBorder = True
              DataField = 'USERORG_ID'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              KeyField = 'ID'
              ListField = 'NAME'
              ListSource = dsc_Orgs
              TabOrder = 1
              Visible = True
            end
            object dbeHeader: TDBEditEh
              Left = 132
              Top = 72
              Width = 313
              Height = 19
              AlwaysShowBorder = True
              DataField = 'DOGHEADER'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              TabOrder = 2
              Visible = True
            end
            object dbneRate: TDBNumberEditEh
              Left = 132
              Top = 96
              Width = 77
              Height = 19
              AlwaysShowBorder = True
              DataField = 'PAY_RATE'
              DataSource = dscRefer
              EditButtons = <>
              Flat = True
              TabOrder = 3
              Visible = True
            end
            object cbActive: TDBCheckBoxEh
              Left = 132
              Top = 120
              Width = 233
              Height = 17
              AlwaysShowBorder = True
              Caption = #1055#1088#1080#1079#1085#1072#1082' '#1072#1082#1090#1091#1072#1083#1100#1085#1086#1089#1090#1080' '#1076#1086#1075#1086#1074#1086#1088#1072
              DataField = 'IS_ACTIVE'
              DataSource = dscRefer
              Flat = True
              TabOrder = 4
              ValueChecked = '1'
              ValueUnchecked = '0'
            end
          end
          object gbAccessList: TGroupBox
            Left = 456
            Top = 15
            Width = 326
            Height = 367
            Align = alClient
            Caption = ' '#1050#1090#1086' '#1084#1086#1078#1077#1090' '#1087#1088#1080#1085#1080#1084#1072#1090#1100' '#1087#1083#1072#1090#1077#1078#1080' '
            TabOrder = 2
            object clbAccessList: TCheckListBox
              Left = 2
              Top = 15
              Width = 322
              Height = 350
              OnClickCheck = clbAccessListClickCheck
              Align = alClient
              BorderStyle = bsNone
              ItemHeight = 13
              TabOrder = 0
            end
          end
        end
      end
    end
  end
  inherited GroupBox1: TGroupBox
    Height = 0
    Enabled = False
    Visible = False
  end
  inherited dsRefer: TpFIBDataSet
    UpdateSQL.Strings = (
      'UPDATE RTP_DOGOVORS'
      'SET '
      '    DOGHEADER = :DOGHEADER,'
      '    PAY_RATE = :PAY_RATE,'
      '    IS_ACTIVE = :IS_ACTIVE'
      'WHERE'
      '    ID = :OLD_ID'
      '    ')
    DeleteSQL.Strings = (
      'DELETE FROM'
      '    RTP_DOGOVORS'
      'WHERE'
      '        ID = :OLD_ID'
      '    ')
    InsertSQL.Strings = (
      'INSERT INTO RTP_DOGOVORS('
      '    USERORG_ID,'
      '    RPT_GROUP_ID,'
      '    DOGHEADER,'
      '    PAY_RATE'
      ')'
      'VALUES('
      '    :USERORG_ID,'
      '    :RPT_GROUP_ID,'
      '    :DOGHEADER,'
      '    :PAY_RATE'
      ')')
    RefreshSQL.Strings = (
      'select rd.id,'
      '       rd.userorg_id, '
      '       rd.rpt_group_id, '
      '       rd.dogheader, '
      '       rd.pay_rate, '
      '       rd.is_active,'
      '       u.name as org_name,'
      '       rg.name as group_name'
      'from rtp_dogovors rd'
      'join rtp_groups rg on rg.id = rd.rpt_group_id'
      'join userorg u on u.id = rd.userorg_id'
      ''
      ' WHERE '
      '        RD.ID = :OLD_ID'
      '    ')
    SelectSQL.Strings = (
      'select rd.id,'
      '       rd.userorg_id, '
      '       rd.rpt_group_id, '
      '       rd.dogheader, '
      '       rd.pay_rate, '
      '       rd.is_active,'
      '       u.name as org_name,'
      '       rg.name as group_name'
      'from rtp_dogovors rd'
      'join rtp_groups rg on rg.id = rd.rpt_group_id'
      'join userorg u on u.id = rd.userorg_id')
    UpdateTransaction = trRefer
    object dsReferID: TFIBIntegerField
      DisplayLabel = #1048#1044
      FieldName = 'ID'
    end
    object dsReferUSERORG_ID: TFIBIntegerField
      FieldName = 'USERORG_ID'
    end
    object dsReferRPT_GROUP_ID: TFIBIntegerField
      FieldName = 'RPT_GROUP_ID'
    end
    object dsReferDOGHEADER: TFIBStringField
      DisplayLabel = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103'-'#1087#1086#1083#1091#1095#1072#1090#1077#1083#1100
      DisplayWidth = 30
      FieldName = 'DOGHEADER'
      Size = 120
      EmptyStrToNull = True
    end
    object dsReferPAY_RATE: TFIBBCDField
      DisplayLabel = #1057#1090#1072#1074#1082#1072' '#1082#1086#1084#1080#1089#1089#1080#1080' '#1089#1074#1077#1088#1093' '#1087#1083#1072#1090#1077#1078#1072
      FieldName = 'PAY_RATE'
      Size = 2
      RoundByScale = True
    end
    object dsReferIS_ACTIVE: TFIBSmallIntField
      DisplayLabel = #1055#1088#1080#1079#1085#1072#1082' '#1072#1082#1090#1091#1072#1083#1100#1085#1086#1089#1090#1080' '#1076#1086#1075#1086#1074#1086#1088#1072
      FieldName = 'IS_ACTIVE'
    end
    object dsReferORG_NAME: TFIBStringField
      DisplayLabel = #1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103' '#1085#1072#1079#1085#1072#1095#1077#1085#1080#1103
      DisplayWidth = 30
      FieldName = 'ORG_NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object dsReferGROUP_NAME: TFIBStringField
      DisplayLabel = #1059#1089#1083#1091#1075#1072
      DisplayWidth = 20
      FieldName = 'GROUP_NAME'
      Size = 120
      EmptyStrToNull = True
    end
  end
  inherited Timer1: TTimer
    Left = 566
    Top = 109
  end
  inherited trLists: TpFIBTransaction
    Left = 522
    Top = 105
  end
  inherited PropStorage: TPropStorageEh
    Left = 84
  end
  object ds_Groups: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    NAME,'
      '    IS_ACTIVE'
      'FROM'
      '    RTP_GROUPS '
      'order by 2')
    AfterCancel = dsReferAfterRefresh
    AfterEdit = dsReferAfterEdit
    AfterInsert = dsReferAfterInsert
    AfterOpen = dsReferAfterRefresh
    AfterRefresh = dsReferAfterRefresh
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    AfterFetchRecord = dsReferAfterFetchRecord
    Left = 284
    Top = 156
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object ds_GroupsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_GroupsNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 120
      EmptyStrToNull = True
    end
    object ds_GroupsIS_ACTIVE: TFIBSmallIntField
      FieldName = 'IS_ACTIVE'
    end
  end
  object dsc_Groups: TDataSource
    DataSet = ds_Groups
    Left = 316
    Top = 156
  end
  object ds_Orgs: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    ID,'
      '    NAME'
      'FROM'
      '    USERORG '
      'order by 2')
    AfterCancel = dsReferAfterRefresh
    AfterEdit = dsReferAfterEdit
    AfterInsert = dsReferAfterInsert
    AfterOpen = dsReferAfterRefresh
    AfterRefresh = dsReferAfterRefresh
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    AfterFetchRecord = dsReferAfterFetchRecord
    Left = 284
    Top = 204
    oRefreshAfterDelete = True
    oRefreshDeletedRecord = True
    oFetchAll = True
    object ds_OrgsID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_OrgsNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
  end
  object dsc_Orgs: TDataSource
    DataSet = ds_Orgs
    Left = 316
    Top = 204
  end
  object dsOrgList: TpFIBDataSet
    SelectSQL.Strings = (
      'select'
      ' distinct uo.id, uo.name,'
      ' (case when exists('
      '  select first(1) 1 from rtp_agents ra'
      '  where ra.rtp_dog_id = :pdog_id'
      '    and ra.userorg_id = uo.id'
      ' ) then 1 else 0 end) as access'
      'from userorg uo'
      '  join username un on un.orgcode = uo.id'
      '    and un.access = 1'
      '  join rdb$user_privileges ug on un.namemag = ug.rdb$user'
      
        '    and rdb$relation_name in ('#39'GRAD_CASHIER'#39', '#39'GRAD_EDIT_CASHIER' +
        #39')')
    Transaction = trLists
    Database = MAINDM.pMainDatabase
    Left = 526
    Top = 298
    object dsOrgListID: TFIBIntegerField
      FieldName = 'ID'
    end
    object dsOrgListNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object dsOrgListACCESS: TFIBIntegerField
      FieldName = 'ACCESS'
    end
  end
  object trAgent: TpFIBTransaction
    DefaultDatabase = MAINDM.pMainDatabase
    TimeoutAction = TARollback
    Left = 566
    Top = 254
  end
  object prAgentSet: TpFIBStoredProc
    Transaction = trAgent
    Database = MAINDM.pMainDatabase
    SQL.Strings = (
      
        'EXECUTE PROCEDURE PROC_RTP_AGENTS_SET (:PORG_ID, :PDOG_ID, :PACC' +
        'ESS)')
    StoredProcName = 'PROC_RTP_AGENTS_SET'
    Left = 522
    Top = 256
    qoAutoCommit = True
    qoStartTransaction = True
  end
end
